package com.niit.servlet;

import com.niit.pojo.downFile;
import com.niit.service.HadoopService;
import com.niit.service.impl.HadoopServiceImpl;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.UnsupportedEncodingException;

/**
 * @author Liu
 * @date 2022/2/13 14:38
 **/
@WebServlet("/downloadServlet")
public class downloadServlet extends HttpServlet {
    public void init(HttpServletRequest req, HttpServletResponse resp) throws UnsupportedEncodingException {
        req.setCharacterEncoding("utf-8");
        resp.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;charset=utf-8");
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String file_url = req.getParameter("file_url");
        System.out.println(file_url);
        HadoopService hadoopService = new HadoopServiceImpl();
        hadoopService.download(file_url);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doPost(req, resp);
    }

}

